package com.dq.domain.record;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;

import com.dq.domain.org.Org;
import com.dq.domain.sys.user.user.base.SysUser;
import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

/**
 * @Author luchangtong
 * @Date 2020/3/18 9:55
 */
@Data
@Entity
@ApiModel("跟踪记录")
public class TrackRecord  extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("跟踪用户")
    @ManyToOne
    protected SysUser wxUser;

    @ApiModelProperty("跟踪技师")
    @ManyToOne
    protected SysUser staffUser;

    @ApiModelProperty("跟踪内容")
    protected String trackContent;

    @ApiModelProperty("记录所属门店")
    @ManyToOne
    protected Org sysDept;

    @Data
    public static class Vo implements VO{
        protected Long id;
        protected Long wxUserId;
        protected String wxUserRealcName;
        protected String wxUserCardNo;
        protected Long staffUserId;
        protected String staffUserRealcName;
        @ApiModelProperty("跟踪内容")
        protected String trackContent;
        protected Long orgId;
        protected String orgName;


        @ApiModelProperty(value = "创建时间")
        private String createTime;
        @ApiModelProperty(value = "修改时间")
        private String lastModifyTime;
        @ApiModelProperty(value = "创建者id")
        private Long createUserId;
        @ApiModelProperty(value = "创建者name")
        private String createUserName;
        @ApiModelProperty(value = "修改者id")
        private Long updateUserId;
        @ApiModelProperty(value = "修改者name")
        private String updateUserName;

    }
    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.getId();
        vo.wxUserId = this.getWxUser()!= null? this.getWxUser().getId():null;
        vo.wxUserRealcName = this.getWxUser()!= null? this.getWxUser().getUserRealcName():"";
        vo.wxUserCardNo = this.getWxUser()!= null? this.getWxUser().getCardNo():"";
        vo.staffUserId = this.getStaffUser()!=null?this.getStaffUser().getId():null;
        vo.staffUserRealcName = this.getStaffUser()!=null?this.getStaffUser().getUserRealcName():"";
        vo.trackContent = this.getTrackContent();
        vo.orgId = this.getSysDept()!=null?this.getSysDept().getId():null;
        vo.orgName = this.getSysDept()!=null?this.getSysDept().getSimpleName():"";

        vo.createTime = TimeUtil.longToString(this.createTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.lastModifyTime = TimeUtil.longToString(this.lastModifyTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.createUserId = this.createUser == null ? null : this.createUser.getId();
        vo.createUserName = this.createUser == null ? null : this.createUser.getUsername();
        vo.updateUserId = this.updateUser == null ? null : this.updateUser.getId();
        vo.updateUserName = this.updateUser == null ? null : this.updateUser.getUsername();
        return vo;
    }
}
